package ro.licenta.utilities.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class PreferencesUtils {

	private Context mContext;
	private SharedPreferences mPrefs;

	public PreferencesUtils(Context context) {
		mContext = context;
		mPrefs = mContext.getSharedPreferences("tama",
				Context.MODE_MULTI_PROCESS);
	}

	private final String sHp = "health";
	private final String sFun = "fun";
	private final String sFull = "fullness";
	private final String sEne = "energy";
	private final String sAge = "age";
	private final String gameStarted = "gamestarted";
	private final String isSleeping = "sleeping";

	public synchronized int getEne(int val) {
		int ret = mPrefs.getInt(sEne, val);
		return ret;
	}

	public synchronized int getFull(int val) {
		int ret = mPrefs.getInt(sFull, val);
		return ret;
	}

	public synchronized int getFun(int val) {
		int ret = mPrefs.getInt(sFun, val);
		return ret;
	}

	public synchronized int getHp(int val) {
		int ret = mPrefs.getInt(sHp, val);
		return ret;
	}

	public synchronized int getAge(int val) {
		int ret = mPrefs.getInt(sAge, val);
		return ret;
	}

	public synchronized boolean getGameStarted() {
		boolean ret = mPrefs.getBoolean(gameStarted, false);
		return ret;
	}

	public synchronized boolean getSleeping() {
		boolean ret = mPrefs.getBoolean(isSleeping, false);
		return ret;
	}

	public synchronized void setHp(int val) {
		SharedPreferences.Editor editor = mPrefs.edit();
		editor.putInt(sHp, val);
		editor.commit();
	}

	public synchronized void setFun(int val) {
		SharedPreferences.Editor editor = mPrefs.edit();
		editor.putInt(sFun, val);
		editor.commit();
	}

	public synchronized void setFull(int val) {
		SharedPreferences.Editor editor = mPrefs.edit();
		editor.putInt(sFull, val);
		editor.commit();
	}

	public synchronized void setEne(int val) {
		SharedPreferences.Editor editor = mPrefs.edit();
		editor.putInt(sEne, val);
		editor.commit();
	}

	public synchronized void setAge(int val) {
		SharedPreferences.Editor editor = mPrefs.edit();
		editor.putInt(sAge, val);
		editor.commit();
	}

	public synchronized void setGameStarted(boolean val) {
		SharedPreferences.Editor editor = mPrefs.edit();
		editor.putBoolean(gameStarted, val);
		editor.commit();
	}

	public synchronized void setSleeping(boolean val) {
		SharedPreferences.Editor editor = mPrefs.edit();
		editor.putBoolean(isSleeping, val);
		editor.commit();
	}

	public synchronized void ResetCache() {
		SharedPreferences.Editor editor = mPrefs.edit();
		editor.clear();
		editor.putInt(sHp, -1);
		editor.putInt(sFun, -1);
		editor.putInt(sFull, -1);
		editor.putInt(sEne, -1);
		editor.commit();
	}
}
